<%@ taglib uri="http://www.rapid-framework.org.cn/rapid" prefix="rapid"%>
<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<rapid:override name="frame-header-style">
	<link rel="stylesheet" href="resources/css/index-page.css">
</rapid:override>

<rapid:override name="frame-header-script">
	<style>
		.layui-input-block{
			float:left;
			width:1050px;
		}
		.d{
			display :  inline;
		}
	</style>
	<script type="text/javascript" src="resources/js/jquery.min.js"></script>
	<script>
		$(function() {
			
			//昵称commentAuthorName
			$("#commentAuthorName").blur(commentAuthorNam);
			function commentAuthorNam(){
				var r=false;
				var reg=/^[^\s]{1,20}$/;
				if( !reg.test($("#commentAuthorName").val()) ){
					$("#commentAuthorName_msg").html("<font color='red'>昵称不合法.请输入1-20位字符</font>");
				}else{
					$("#commentAuthorName_msg").html("");
					r=true;
				}
				return r;
			}
			
			//邮箱commentAuthorEmail
			$("#commentAuthorEmail").blur(commentAuthorEmai);
			function commentAuthorEmai(){
				var r=false;
				var reg=/^[^\s]{1,20}$/;
				if( !reg.test($("#commentAuthorEmail").val()) ){
					$("#commentAuthorEmail_msg").html("<font color='red'>邮箱不合法</font>");
				}else{
					$("#commentAuthorEmail_msg").html("");
					r=true;
				}
				return r;
			}
			
			//网址commentAuthorUrl
			$("#commentAuthorUrl").blur(commentAuthorUr);
			function commentAuthorUr(){
				var r=false;
				var reg=/^[^\s]{1,25}$/;
				if( !reg.test($("#commentAuthorUrl").val()) ){
					$("#commentAuthorUrl_msg").html("<font color='red'>url不合法</font>");
				}else{
					$("#commentAuthorUrl_msg").html("");
					r=true;
				}
				return r;
			}
			
			//回复commentContent
			$("#commentContent").blur(commentConten);
			function commentConten(){
				var r=false;
				var reg=/^[^\s]{1,255}$/;
				if( !reg.test($("#commentContent").html()) ){
					$("#commentContent_msg").html("<font color='red'>内容不合法,1-255个字符</font>");
				}else{
					$("#commentContent_msg").html("");
					r=true;
				}
				return r;
			}
			
			//回复按钮
			$("#subm").click(function(){
				var r=true;

				if(!commentAuthorNam()){
					r=false;
				}
				
				if(!commentAuthorEmai()){
					r=false;
				}
				
				if(!commentAuthorUr()){
					r=false;
				}
				
				if(!commentConten()){
					r=false;
				}
				
				if(r){
					r=confirm("确定提交回复吗");
				}
				return r;
			});
			
		});
	</script>
</rapid:override>

<rapid:override name="frame-content">
	<!-- 内容主体区域 -->
	<div style="padding: 15px;">
		<blockquote class="layui-elem-quote">
			<span class="layui-breadcrumb" lay-separator="/"> 
			<a href="Login">首页</a> <a href="comment/commentList">评论列表</a> <a><cite>回复评论</cite></a>
			</span>
		</blockquote>

		<form class="layui-form" method="post" id="myForm" action="comment/addComment">
			<input type="hidden" name="commentPid" value="${comment.commentPid }"> 
			<input type="hidden" name="commentPname" value="${comment.commentPname }"> 
			<input type="hidden" name="commentArticleId" value="${comment.commentArticleId }"> 
			<input type="hidden" name="commentRole" value="1">

			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">原内容</label>
				<div class="layui-input-block">
					<textarea class="layui-textarea" disabled>${comment.commentContent }</textarea>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">我的昵称 </label>
				<div class="layui-input-block">
					<input type="text" name="commentAuthorName" id="commentAuthorName" class="layui-input">
					<span id="commentAuthorName_msg" ></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">我的邮箱 </label>
				<div class="layui-input-block">
					<input type="text" name="commentAuthorEmail" id="commentAuthorEmail" class="layui-input">
					<span id="commentAuthorEmail_msg"></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">我的网址 </label>
				<div class="layui-input-block">
					<input type="text" name="commentAuthorUrl" id="commentAuthorUrl" class="layui-input">
					<span id="commentAuthorUrl_msg"></span>
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">我的回复</label>
				<div class="layui-input-block">
					<textarea name="commentContent" id="commentContent" class="layui-textarea"></textarea>
					<span id="commentContent_msg"></span>
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<div class="d">
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					</div>
					<button class="layui-btn" id="subm" lay-submit="" lay-filter="demo1">回复</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>

		</form>
	</div>
</rapid:override>

<%@ include file="../framework.jsp"%>